Name: Portal System Addon: Top Ten Referrers v1.2

Last modified: 06/22/2009

Description:
This modification will add a "Top 10 Referrers" block to your portal.
This modification is dependent on the XMB Portal System v4.0 And the Referrals v1.7 modifications.

Compatibility: XMB v1.9.8 SP3

Tested On: XMB 1.9.8 SP3

Code Developed By: Adam Clarke (http://www.adam-clarke.co.uk)

MOD History: V1.0 (06/08/2005 @ 01:10) - Initial Release.
                         V1.1 (06/08/2005 @ 02:55) - Added instructions for OLD referral mod.
                         V1.2 (19/08/2005 @ 19:05) - Replaced 'xmb_' with '$table_'.
                         V1.2 (05/16/2006 @ 01:17) - Updated for 1.9.5 by: WormHole @ XMB Garage.
                         V1.2 (06/22/2009 @ 19:30) - Updated for 1.9.8 by: WormHole @ XMB Garage.

License Note: This modification is released under the GPL License. A copy is provided with this software package.

Note: Backup all affected files, templates & database.

Affected Files: portal.php, lang/English.lang.php

Affected Templates: NONE

====================================================================================================
========
STEP 1:
========
================
Edit File: portal.php
================
==========
Find Code:
==========

loadtemplates(

================
Replace Code With:
================

loadtemplates(
'portal_top_referrers',

==========
Find Code:
==========

$sql = $db->query("SELECT p.*, t.* FROM ".X_PREFIX."portal_templates p LEFT JOIN ".X_PREFIX."templates t ON t.name=p.name WHERE p.status='on' ORDER BY p.displayorder ASC LIMIT 0, 30");

===============
Add Code Above:
===============

// Portal System Addon: Top Ten Referrers Mod Begin
$top_referrers = array();
$query = $db->query("SELECT count(m.uid) as count, m.username FROM ".X_PREFIX."members r LEFT JOIN ".X_PREFIX."members m ON r.referredby = m.uid WHERE r.referredby > 0 GROUP BY r.referredby ORDER BY count DESC LIMIT 0, 10");
while ($top_referrer = $db->fetch_array($query)) {
    $top_referrers[] = "<tr>\n<td class=\"tablerow\" bgcolor=\"$THEME[altbg2]\"><a href=\"./member.php?action=viewpro&amp;member=".rawurlencode($top_referrer['username'])."\">$top_referrer[username]</a></td><td class=\"tablerow\" bgcolor=\"$THEME[altbg1]\">$top_referrer[count]</td>\n</tr>";
}
$top_referrers = implode("\n", $top_referrers);
// Portal System Addon: Top Ten Referrers Mod End

====================================================================================================
========
STEP 1:
========
========================
Edit File: lang/English.portal.php
========================
==========
Find Code:
==========
============================
Add Code To End Of File Above ?>
============================

// Portal System Addon: Top Ten Referrers Mod Begin
$lang['top_referrers'] = "&raquo; Top 10 Referrers";
// Portal System Addon: Top Ten Referrers Mod End

====================================================================================================
========
STEP 3:
========
==================================
Create New Portal Block: portal_top_referrers
==================================
===================
Add Code And Submit:
===================

<table cellspacing="0" cellpadding="0" border="0" width="100%" bgcolor="$THEME[bordercolor]">
<tr>
<td>
<table border="0" cellspacing="$THEME[borderwidth]" cellpadding="$THEME[tablespace]" width="100%">
<tr>
<td class="category" colspan="2"><strong><font color="$THEME[cattext]">$lang[top_referrers]</font></strong></td>
$top_referrers
</table>
</td>
</tr>
</table>

====================================================================================================
Enjoy!